package com.nuaa.yupicturebackend.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.nuaa.yupicturebackend.model.dto.picture.PictureQueryRequest;
import com.nuaa.yupicturebackend.model.dto.picture.PictureReviewRequest;
import com.nuaa.yupicturebackend.model.dto.picture.PictureUploadByBatchRequest;
import com.nuaa.yupicturebackend.model.dto.picture.PictureUploadRequest;
import com.nuaa.yupicturebackend.model.entity.Picture;
import com.nuaa.yupicturebackend.model.entity.User;
import com.nuaa.yupicturebackend.model.vo.PictureVO;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

/**
 * @author 11352
 * @description 针对表【picture(图片)】的数据库操作Service
 * @createDate 2024-12-12 18:19:02
 */
public interface PictureService extends IService<Picture> {
    /**
     * 上传图片
     *
     * @param inputSource
     * @param pictureUploadRequest
     * @param loginUser
     * @return
     */
    PictureVO uploadPicture(Object inputSource,
                            PictureUploadRequest pictureUploadRequest,
                            User loginUser);

    /**
     * 查询图片列表
     *
     * @param pictureQueryRequest
     * @return
     */
    QueryWrapper<Picture> getQueryWrapper(PictureQueryRequest pictureQueryRequest);

    PictureVO getPictureVO(Picture picture, HttpServletRequest request);

    /**
     * 获取到封装类
     *
     * @param picturePage
     * @param request
     * @return
     */
    Page<PictureVO> getPictureVOPage(Page<Picture> picturePage, HttpServletRequest request);

    /**
     * 校验图片
     *
     * @param picture
     */
    void validPicture(Picture picture);

    /**
     * 审核图片
     */
    void checkPicture(PictureReviewRequest pictureReviewRequest, User loginUser);

    /**
     * 填充图片审核信息
     * @param picture
     * @param loginUser
     */
     void fillPictureParam(Picture picture,User loginUser);

    /**
     * 批量抓取和创建图片
     *
     * @param pictureUploadByBatchRequest 请求数量
     * @param loginUser 登录用户
     * @return 成功创建的图片数
     */
    Integer uploadPictureByBatch(
            PictureUploadByBatchRequest pictureUploadByBatchRequest,
            User loginUser
    );

    /**
     * 删除COS里面的图片
     * @param url 图片url
     */
    void deletePicture(String url);

    /**
     * 检验访问图片的权限
     * @param loginUser
     * @param picture
     */
    void checkPictureAuth(User loginUser, Picture picture);
}
